package com.pai4j.domain.community;
import com.pai4j.domain.vo.response.UserBaseResponseInfoVO;
import com.pai4j.pgc.entity.community.CCQuestionEntity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.StringUtils;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 *
 *
 * @author: CYM-pai
 * @date: 2025/10/28 20:41
 **/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class CTCHomeRecommendQuestionVO {

    private Long id;

    private String title;

    private String description;

    private List<String> images;

    private List<String> signs;

    private String recommendReason;

    private Long joinUserCount;

    private Long viewCount;

    private Long time;

    private String author;

    private UserBaseResponseInfoVO authorUser;

    private Boolean free;

    public CTCHomeRecommendQuestionVO(CCQuestionEntity question, String recommendReason) {
        this.id = question.getId();
        this.title = question.getTitle();
        this.time = question.getCreateDate().getTime();
        this.description = question.getDescription();
        this.author = question.getAuthor();
        this.recommendReason = recommendReason;
        this.free = question.getFree();
        this.images = new ArrayList<>();
        if (StringUtils.isNotBlank(question.getImages())) {
            this.images = Arrays.stream(question.getImages().split(",")).collect(Collectors.toList());
        }
        this.signs = new ArrayList<>();
        if (StringUtils.isNotBlank(question.getSigns())) {
            this.signs = Arrays.stream(question.getSigns().split(",")).collect(Collectors.toList());
        }
    }
}
